Optimal. Leaf size=205 \[ -\frac {a^3 \left (A \left (15+11 m+2 m^2\right )-i B \left (17+11 m+2 m^2\right )\right ) \tan ^{1+m}(c+d x)}{d (1+m) (2+m) (3+m)}+\frac {4 a^3 (A-i B) \, _2F_1(1,1+m;2+m;i \tan (c+d x)) \tan ^{1+m}(c+d x)}{d (1+m)}+\frac {i a B \tan ^{1+m}(c+d x) (a+i a \tan (c+d x))^2}{d (3+m)}-\frac {(A (3+m)-i B (5+m)) \tan ^{1+m}(c+d x) \left (a^3+i a^3 \tan (c+d x)\right )}{d (2+m) (3+m)} \]
[Out]
________________________________________________________________________________________
Rubi [A]
time = 0.46, antiderivative size = 205, normalized size of antiderivative = 1.00, number of steps
used = 6, number of rules used = 5, integrand size = 34, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.147, Rules used = {3675, 3673,
3618, 12, 66} \begin {gather*} \frac {4 a^3 (A-i B) \tan ^{m+1}(c+d x) \, _2F_1(1,m+1;m+2;i \tan (c+d x))}{d (m+1)}-\frac {a^3 \left (A \left (2 m^2+11 m+15\right )-i B \left (2 m^2+11 m+17\right )\right ) \tan ^{m+1}(c+d x)}{d (m+1) (m+2) (m+3)}-\frac {(A (m+3)-i B (m+5)) \left (a^3+i a^3 \tan (c+d x)\right ) \tan ^{m+1}(c+d x)}{d (m+2) (m+3)}+\frac {i a B (a+i a \tan (c+d x))^2 \tan ^{m+1}(c+d x)}{d (m+3)} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
Rule 12
Rule 66
Rule 3618
Rule 3673
Rule 3675
Rubi steps
\begin {align*} \int \tan ^m(c+d x) (a+i a \tan (c+d x))^3 (A+B \tan (c+d x)) \, dx &=\frac {i a B \tan ^{1+m}(c+d x) (a+i a \tan (c+d x))^2}{d (3+m)}+\frac {\int \tan ^m(c+d x) (a+i a \tan (c+d x))^2 (-a (i B (1+m)-A (3+m))+a (i A (3+m)+B (5+m)) \tan (c+d x)) \, dx}{3+m}\\ &=\frac {i a B \tan ^{1+m}(c+d x) (a+i a \tan (c+d x))^2}{d (3+m)}-\frac {(A (3+m)-i B (5+m)) \tan ^{1+m}(c+d x) \left (a^3+i a^3 \tan (c+d x)\right )}{d (2+m) (3+m)}+\frac {\int \tan ^m(c+d x) (a+i a \tan (c+d x)) \left (-a^2 \left (i B \left (7+9 m+2 m^2\right )-A \left (9+9 m+2 m^2\right )\right )+a^2 \left (i A \left (15+11 m+2 m^2\right )+B \left (17+11 m+2 m^2\right )\right ) \tan (c+d x)\right ) \, dx}{6+5 m+m^2}\\ &=-\frac {a^3 \left (A \left (15+11 m+2 m^2\right )-i B \left (17+11 m+2 m^2\right )\right ) \tan ^{1+m}(c+d x)}{d (1+m) \left (6+5 m+m^2\right )}+\frac {i a B \tan ^{1+m}(c+d x) (a+i a \tan (c+d x))^2}{d (3+m)}-\frac {(A (3+m)-i B (5+m)) \tan ^{1+m}(c+d x) \left (a^3+i a^3 \tan (c+d x)\right )}{d (2+m) (3+m)}+\frac {\int \tan ^m(c+d x) \left (4 a^3 (A-i B) (2+m) (3+m)+4 a^3 (i A+B) (2+m) (3+m) \tan (c+d x)\right ) \, dx}{6+5 m+m^2}\\ &=-\frac {a^3 \left (A \left (15+11 m+2 m^2\right )-i B \left (17+11 m+2 m^2\right )\right ) \tan ^{1+m}(c+d x)}{d (1+m) \left (6+5 m+m^2\right )}+\frac {i a B \tan ^{1+m}(c+d x) (a+i a \tan (c+d x))^2}{d (3+m)}-\frac {(A (3+m)-i B (5+m)) \tan ^{1+m}(c+d x) \left (a^3+i a^3 \tan (c+d x)\right )}{d (2+m) (3+m)}+\frac {\left (16 i a^6 (A-i B)^2 (2+m) (3+m)\right ) \text {Subst}\left (\int \frac {4^{-m} \left (\frac {x}{a^3 (i A+B) (2+m) (3+m)}\right )^m}{16 a^6 (i A+B)^2 (2+m)^2 (3+m)^2+4 a^3 (A-i B) (2+m) (3+m) x} \, dx,x,4 a^3 (i A+B) (2+m) (3+m) \tan (c+d x)\right )}{d}\\ &=-\frac {a^3 \left (A \left (15+11 m+2 m^2\right )-i B \left (17+11 m+2 m^2\right )\right ) \tan ^{1+m}(c+d x)}{d (1+m) \left (6+5 m+m^2\right )}+\frac {i a B \tan ^{1+m}(c+d x) (a+i a \tan (c+d x))^2}{d (3+m)}-\frac {(A (3+m)-i B (5+m)) \tan ^{1+m}(c+d x) \left (a^3+i a^3 \tan (c+d x)\right )}{d (2+m) (3+m)}+\frac {\left (i 4^{2-m} a^6 (A-i B)^2 (2+m) (3+m)\right ) \text {Subst}\left (\int \frac {\left (\frac {x}{a^3 (i A+B) (2+m) (3+m)}\right )^m}{16 a^6 (i A+B)^2 (2+m)^2 (3+m)^2+4 a^3 (A-i B) (2+m) (3+m) x} \, dx,x,4 a^3 (i A+B) (2+m) (3+m) \tan (c+d x)\right )}{d}\\ &=-\frac {a^3 \left (A \left (15+11 m+2 m^2\right )-i B \left (17+11 m+2 m^2\right )\right ) \tan ^{1+m}(c+d x)}{d (1+m) \left (6+5 m+m^2\right )}+\frac {4 a^3 (A-i B) \, _2F_1(1,1+m;2+m;i \tan (c+d x)) \tan ^{1+m}(c+d x)}{d (1+m)}+\frac {i a B \tan ^{1+m}(c+d x) (a+i a \tan (c+d x))^2}{d (3+m)}-\frac {(A (3+m)-i B (5+m)) \tan ^{1+m}(c+d x) \left (a^3+i a^3 \tan (c+d x)\right )}{d (2+m) (3+m)}\\ \end {align*}
________________________________________________________________________________________
Mathematica [B] Both result and optimal contain complex but leaf count is larger than twice
the leaf count of optimal. \(1305\) vs. \(2(205)=410\).
time = 8.73, size = 1305, normalized size = 6.37 \begin {gather*} \frac {2^{2-m} (i A+B) e^{-i c} \left (-\frac {i \left (-1+e^{2 i (c+d x)}\right )}{1+e^{2 i (c+d x)}}\right )^m \cos ^4(c+d x) \left (2^m \, _2F_1\left (1,m;1+m;-\frac {-1+e^{2 i (c+d x)}}{1+e^{2 i (c+d x)}}\right )-\left (1+e^{2 i (c+d x)}\right )^m \, _2F_1\left (m,m;1+m;\frac {1}{2} \left (1-e^{2 i (c+d x)}\right )\right )\right ) (a+i a \tan (c+d x))^3 (A+B \tan (c+d x))}{d \left (1+e^{2 i c}\right ) m (\cos (d x)+i \sin (d x))^3 (A \cos (c+d x)+B \sin (c+d x))}-\frac {4 i (A-i B) e^{-3 i c} \left (-1+e^{2 i (c+d x)}\right )^m \left (-\frac {i \left (-1+e^{2 i (c+d x)}\right )}{1+e^{2 i (c+d x)}}\right )^m \left (\frac {-1+e^{2 i (c+d x)}}{1+e^{2 i (c+d x)}}\right )^{-m} \cos ^4(c+d x) \left (-\frac {\left (1+e^{2 i (c+d x)}\right )^{-m} \, _2F_1\left (1,m;1+m;\frac {1-e^{2 i (c+d x)}}{1+e^{2 i (c+d x)}}\right )}{m}-\frac {\left (1+e^{2 i c}\right ) \left (-1+e^{2 i (c+d x)}\right ) \left (1+e^{2 i (c+d x)}\right )^{-1-m} \, _2F_1\left (1,1+m;2+m;\frac {1-e^{2 i (c+d x)}}{1+e^{2 i (c+d x)}}\right )}{1+m}+\frac {2^{-m} \, _2F_1\left (m,m;1+m;\frac {1}{2} \left (1-e^{2 i (c+d x)}\right )\right )}{m}\right ) (a+i a \tan (c+d x))^3 (A+B \tan (c+d x))}{d \left (1+e^{2 i c}\right ) (\cos (d x)+i \sin (d x))^3 (A \cos (c+d x)+B \sin (c+d x))}+\frac {\cos ^4(c+d x) \left (\frac {(A-3 i B) \sec ^2(c+d x) (-i \cos (3 c)-\sin (3 c))}{2+m}+\frac {(A-3 i B) (-3-2 m+\cos (2 c)) \sec ^2(c) \left (-\frac {1}{2} i \cos (3 c)-\frac {1}{2} \sin (3 c)\right )}{(1+m) (2+m)}+\frac {(i A \cos (c-d x)+3 B \cos (c-d x)-i A \cos (c+d x)-3 B \cos (c+d x)) \sec ^2(c) \sec (c+d x) \left (\frac {1}{2} \cos (3 c)-\frac {1}{2} i \sin (3 c)\right )}{1+m}\right ) \tan ^m(c+d x) (a+i a \tan (c+d x))^3 (A+B \tan (c+d x))}{d (\cos (d x)+i \sin (d x))^3 (A \cos (c+d x)+B \sin (c+d x))}+\frac {\cos ^4(c+d x) \left (\frac {\sec ^2(c) \sec (c+d x) \left (\frac {1}{2} \cos (3 c)-\frac {1}{2} i \sin (3 c)\right ) (-i A \cos (c-d x)-3 B \cos (c-d x)+i A \cos (c+d x)+3 B \cos (c+d x)+3 A \sin (c-d x)-5 i B \sin (c-d x)-3 A \sin (c+d x)+5 i B \sin (c+d x))}{1+m}+\frac {\sec (c) (3 A \cos (c)-5 i B \cos (c)+i A \sin (c)+3 B \sin (c)) (-\cos (3 c)+i \sin (3 c)) \tan (c)}{1+m}\right ) \tan ^m(c+d x) (a+i a \tan (c+d x))^3 (A+B \tan (c+d x))}{d (\cos (d x)+i \sin (d x))^3 (A \cos (c+d x)+B \sin (c+d x))}+\frac {\cos ^4(c+d x) \left (-\frac {i B \sec (c) \sec ^3(c+d x) (\cos (3 c)-i \sin (3 c)) \sin (d x)}{3+m}-\frac {i B \sec (c) \sec (c+d x) (2 \cos (3 c)-2 i \sin (3 c)) \sin (d x)}{(1+m) (3+m)}-\frac {i B \sec ^2(c+d x) (\cos (3 c)-i \sin (3 c)) \tan (c)}{3+m}-\frac {i (2 B \cos (3 c)-2 i B \sin (3 c)) \tan (c)}{(1+m) (3+m)}\right ) \tan ^m(c+d x) (a+i a \tan (c+d x))^3 (A+B \tan (c+d x))}{d (\cos (d x)+i \sin (d x))^3 (A \cos (c+d x)+B \sin (c+d x))} \end {gather*}
Warning: Unable to verify antiderivative.
[In]
[Out]
________________________________________________________________________________________
Maple [F]
time = 0.33, size = 0, normalized size = 0.00 \[\int \left (\tan ^{m}\left (d x +c \right )\right ) \left (a +i a \tan \left (d x +c \right )\right )^{3} \left (A +B \tan \left (d x +c \right )\right )\, dx\]
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Maxima [F]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \text {Failed to integrate} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Fricas [F]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \text {could not integrate} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Sympy [F]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} - i a^{3} \left (\int i A \tan ^{m}{\left (c + d x \right )}\, dx + \int \left (- 3 A \tan {\left (c + d x \right )} \tan ^{m}{\left (c + d x \right )}\right )\, dx + \int A \tan ^{3}{\left (c + d x \right )} \tan ^{m}{\left (c + d x \right )}\, dx + \int \left (- 3 B \tan ^{2}{\left (c + d x \right )} \tan ^{m}{\left (c + d x \right )}\right )\, dx + \int B \tan ^{4}{\left (c + d x \right )} \tan ^{m}{\left (c + d x \right )}\, dx + \int \left (- 3 i A \tan ^{2}{\left (c + d x \right )} \tan ^{m}{\left (c + d x \right )}\right )\, dx + \int i B \tan {\left (c + d x \right )} \tan ^{m}{\left (c + d x \right )}\, dx + \int \left (- 3 i B \tan ^{3}{\left (c + d x \right )} \tan ^{m}{\left (c + d x \right )}\right )\, dx\right ) \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Giac [F]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \text {could not integrate} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Mupad [F]
time = 0.00, size = -1, normalized size = -0.00 \begin {gather*} \int {\mathrm {tan}\left (c+d\,x\right )}^m\,\left (A+B\,\mathrm {tan}\left (c+d\,x\right )\right )\,{\left (a+a\,\mathrm {tan}\left (c+d\,x\right )\,1{}\mathrm {i}\right )}^3 \,d x \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________